package cn.itcast.exam.web;

import cn.itcast.exam.pojo.User;
import cn.itcast.exam.service.UserService;
import cn.itcast.exam.service.impl.UserServiceimpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet(urlPatterns = "/userServlet")
public class UserServlet extends BaseServlet {

   private UserService userService=new UserServiceimpl();

    private void  login(HttpServletRequest request,HttpServletResponse response ) throws IOException, InvocationTargetException, IllegalAccessException {
        Map<String, String[]> map = request.getParameterMap();
        User user = new User();
        BeanUtils.populate(user,map);

        String resoult=  userService.loginService(user);
     response.getWriter().println(resoult);
    }
}